<!DOCTYPE html>
<html lang="cn-zh">

<head>
  
  <meta charset="utf-8">



<meta name="viewport" content="width=device-width, initial-scale=1.0">


  
    <meta name="description" content=" Windows WIN32、_WIN32、WIN32、WIN64、_WIN64、WIN64 Android ANDROID、__ANDROID__ Linux __linux__ iOS/Mac __APPLE__、TARGET_OS_IPHONE、TARGET_IPHONE_SIMULATOR、TARGET_OS_MAC 代码判断 #if defined(WIN32) || defined(_WIN32) || defined(_WIN32_) || defined(WIN64) || defined(_WIN64) || defined(_WIN64_) #define OS_WINDOWS 1 #elif defined(ANDROID) || defined(__ANDROID__) #define OS_ANDROID 1 #elif defined(__linux__) #define OS_LINUX	1 #elif defined(__APPLE__) || defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) || defined(TARGET_OS_MAC) #define OS_IOS 1 #else #define OS_UNKNOWN 1 #endif ">
  


<meta name="color-scheme" content="light dark">







<meta name="generator" content="Hugo 0.111.2">

<meta content="" name="keywords">
<meta content="各个平台的内置宏定义 - 通通不同-博客" property="og:title">
<meta content="开发的乐趣在于相通而不同 - " property="og:description">

<meta name="msvalidate.01" content="F56ED94B7E86941E3DACEF208F07D329" />

  <title>
    
    各个平台的内置宏定义
     - 通通不同-博客
    
</title>

  <link rel="canonical" href="https://codebeautiful.gitee.io/post/platform_define/">


  








  
    
  
  
  <link rel="stylesheet" href="/css/base.min.4f231885947d13c748c815d93da49f07ab89afb67629f9970b7c054610e88e0b.css" integrity="sha256-TyMYhZR9E8dIyBXZPaSfB6uJr7Z2KfmXC3wFRhDojgs=" crossorigin="anonymous">



</head>

<body>
  <nav class="u-background">
  <div class="u-wrapper">
    <ul class="Banner">
      <li class="Banner-item Banner-item--title">
        <h1 class="Banner-heading">
          <a class="Banner-link u-clickable" href="/">通通不同-博客</a>
        </h1>
      </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/post/">全部</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/categories/">分类</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/tags/">标签</a>
        </li>
      
        <li class="Banner-item">
          <a class="Banner-link u-clickable" href="/about/">关于</a>
        </li>
      
    </ul>
  </div>
</nav>

  <main>
    <div class="u-wrapper">
      <div class="u-padding">
        

  <article>
    <header class="Heading">
  <h2 class="Heading-title">
    <a class="Heading-link u-clickable" href="/post/platform_define/" rel="bookmark">各个平台的内置宏定义</a>
  </h2>
  
    <time datetime="2023-03-28T19:24:03&#43;08:00">28 March, 2023</time>
  
</header>

    <h3 id="windows">
  <a class="Heading-link u-clickable" href="/post/platform_define/#windows">Windows</a>
</h3>
<ul>
<li>WIN32、_WIN32、<em>WIN32</em>、WIN64、_WIN64、<em>WIN64</em></li>
</ul>
<h3 id="android">
  <a class="Heading-link u-clickable" href="/post/platform_define/#android">Android</a>
</h3>
<ul>
<li>ANDROID、<code>__ANDROID__</code></li>
</ul>
<h3 id="linux">
  <a class="Heading-link u-clickable" href="/post/platform_define/#linux">Linux</a>
</h3>
<ul>
<li><code>__linux__</code></li>
</ul>
<h3 id="iosmac">
  <a class="Heading-link u-clickable" href="/post/platform_define/#iosmac">iOS/Mac</a>
</h3>
<ul>
<li><code>__APPLE__</code>、TARGET_OS_IPHONE、TARGET_IPHONE_SIMULATOR、TARGET_OS_MAC</li>
</ul>
<h2 id="代码判断">
  <a class="Heading-link u-clickable" href="/post/platform_define/#%e4%bb%a3%e7%a0%81%e5%88%a4%e6%96%ad">代码判断</a>
</h2>

<pre tabindex="0"><code>#if defined(WIN32) || defined(_WIN32) || defined(_WIN32_) || defined(WIN64) || defined(_WIN64) || defined(_WIN64_)
#define OS_WINDOWS       1
#elif defined(ANDROID) || defined(__ANDROID__)
#define OS_ANDROID       1
#elif defined(__linux__)
#define OS_LINUX	         1
#elif defined(__APPLE__) || defined(TARGET_OS_IPHONE) || defined(TARGET_IPHONE_SIMULATOR) || defined(TARGET_OS_MAC)
#define OS_IOS           1
#else
#define OS_UNKNOWN 1
#endif</code></pre>

    


  

  

  





  <footer>
    
      
    
      
    
      
        <ul class="Tags">
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/c/" rel="tag">c</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/%E7%B3%BB%E7%BB%9F%E5%88%A4%E5%AE%9A/" rel="tag">系统判定</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/android/" rel="tag">Android</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/windows/" rel="tag">Windows</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/linux/" rel="tag">linux</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/ios/" rel="tag">iOS</a>
            </li>
          
            <li class="Tags-item u-background">
              <a class="Tags-link u-clickable" href="/tags/osx/" rel="tag">OSX</a>
            </li>
          
        </ul>
      
    
  </footer>

    
  

  </article>


      </div>
    </div>
  </main>
  
  <footer class="Footer">
    <div class="u-wrapper">
      <div class="u-padding">
        开发的乐趣在于相通而不同
      </div>
    </div>
  </footer>


  <script>
var _hmt = _hmt || [];
(function() {
  var hm = document.createElement("script");
  hm.src = "https://hm.baidu.com/hm.js?d08a2ad355cb7a065a41be081b43297e";
  var s = document.getElementsByTagName("script")[0];
  s.parentNode.insertBefore(hm, s);
})();
</script>

</body>

</html>
